(() => {
  "use strict";

  // 检查URL参数
  const urlParams = new URLSearchParams(window.location.search);
  const hasGid = urlParams.has("gid");

  // 调试日志
  console.log("AuthRedirect Check:", { hasGid, href: window.location.href });

  if (!hasGid) {
    try {
      const encodedUrl = encodeURIComponent(window.location.href);
      window.location.href = `https://shai438a.ad005.onehc.net:5080/auth?returnUrl=${encodedUrl}`;
    } catch (error) {
      console.error("Redirect Failed:", error);
    }
  }
})();

// 保留原有错误监听
window.addEventListener("error", (e) => {
  console.error("Script Error:", e);
});
